<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n">
  <xi:include href="admin.html" />
  <head>
    <title>Components</title>
  </head>

  <body>
    <h2>Manage Components</h2>

    <py:def function="owner_field(default_owner='')">
      <div class="field">
        <label>Owner: <br />
          <py:choose>
            <select py:when="owners" size="1" id="owner" name="owner">
              <option py:for="owner in owners"
                      selected="${owner==default_owner or None}" value="$owner">$owner</option>
              <option py:if="default_owner and default_owner not in owners"
                      selected="selected" value="$default_owner">$default_owner</option>
            </select>
            <input py:otherwise="" type="text" name="owner" value="$default_owner" />
          </py:choose>
        </label>
      </div>
    </py:def>

    <py:choose test="view">
      <form py:when="'detail'" class="mod" id="modcomp" method="post" action="">
        <fieldset>
          <legend>Modify Component:</legend>
          <div class="field">
            <label>Name:<br /><input type="text" name="name" value="$component.name"/></label>
          </div>
          ${owner_field(component.owner)}
          <div class="field">
            <fieldset class="iefix">
              <label for="description" i18n:msg="">
                Description (you may use
                <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a>
                here):
              </label>
              <p>
                <textarea id="description" name="description" class="wikitext trac-resizable"
                          rows="6" cols="60">
$component.description</textarea>
              </p>
            </fieldset>
          </div>
          <div class="buttons">
            <input type="submit" name="cancel" value="${_('Cancel')}" />
            <input type="submit" name="save" value="${_('Save')}" />
          </div>
        </fieldset>
      </form>

      <py:otherwise>
        <form class="addnew" id="addcomponent" method="post" action="">
          <fieldset>
            <legend>Add Component:</legend>
            <div class="field">
              <label>Name:<br /><input type="text" name="name" /></label>
            </div>
            ${owner_field()}
            <div class="buttons">
              <input type="submit" name="add" value="${_('Add')}"/>
            </div>
          </fieldset>
        </form>

        <py:choose>
          <form py:when="components" id="component_table" method="post" action="">
            <table class="listing" id="complist">
              <thead>
                <tr><th class="sel">&nbsp;</th>
                  <th>Name</th><th>Owner</th><th>Default</th>
                </tr>
              </thead>
              <tbody>
                <tr py:for="comp in components">
                  <td class="sel"><input type="checkbox" name="sel" value="$comp.name" /></td>
                  <td class="name">
                    <a href="${panel_href(comp.name)}">$comp.name</a>
                  </td>
                  <td class="owner">$comp.owner</td>
                  <td class="default">
                    <input type="radio" name="default" value="$comp.name"
                           checked="${comp.name==default or None}" />
                  </td>
                </tr>
              </tbody>
            </table>
            <div class="buttons">
              <input type="submit" name="remove" value="${_('Remove selected items')}" />
              <input type="submit" name="apply" value="${_('Apply changes')}" />
            </div>
            <p class="help">
              You can remove all items from this list to completely hide this
              field from the user interface.
            </p>
          </form>

          <p py:otherwise="" class="help">
            As long as you don't add any items to the list, this field
            will remain completely hidden from the user interface.
          </p>
        </py:choose>
      </py:otherwise>
    </py:choose>
  </body>

</html>
